﻿using University.Workshop.Model;
using University.Workshop.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace University.Workshop.Tests
{
    
    
   
    [TestClass()]
    public class ProviderControlTest
    {
        private TestContext testContextInstance;
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        [TestMethod()]
        public void RegisterProviderValid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = "javier@hotmail.com";
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = "patitoweb.com";
            string cellular = "72288997";
            string nit = new Random().Next(100000000).ToString();
            string telephone = "4444444";
            bool expected = true;
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
            DataAccess.DataAccessProvider.ProviderDelete(nit);
            Assert.AreEqual(expected, actual);
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void RegisterProviderExistValid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = "javier@hotmail.com";
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = "patitoweb.com";
            string cellular = "72288997";
            string nit = "1214568";
            string telephone = "4444444";
            bool expected = true;
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
            DataAccess.DataAccessProvider.ProviderDelete(nit);
            Assert.AreEqual(expected, actual);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderNitInvalid()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "74521r8304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderNitLenghtInvalid()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "7452";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderNitEmpty()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = string.Empty;
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderNameInvalid()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "'Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderNameLenghtInvalid()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productionssadddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "74534562";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderNameEmpty()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = string.Empty;
            string web = string.Empty;
            string cellular = "72288997";
            string nit = string.Empty;
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderAddressInvalid()
        {
            string address = "'Cañada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderAddressLenghtInvalid()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143gdfsgdfhfgjghkstfaerwt5uydtkmsgfrnrsn6yjtyda";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "7454322";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderAddressEmpty()
        {
            string address = string.Empty;
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = string.Empty;
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderTelephoneAndCellularEmpty()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = "javier@hotmail.com";
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = "patitoweb.com";
            string cellular = string.Empty;
            string nit = new Random().Next(100000000).ToString();
            string telephone = string.Empty;
            bool expected = true;
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
            DataAccess.DataAccessProvider.ProviderDelete(nit);
            Assert.AreEqual(expected, actual);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderTelephoneInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4t44444";
            bool expected = true;
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
            Assert.AreEqual(expected, actual);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderCellularInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "7y288997";
            string nit = "74521804";
            string telephone = "4444444";
            bool expected = true;
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
            Assert.AreEqual(expected, actual);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderTelephoneLenghtInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "444444444";
            bool expected = true;
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
            Assert.AreEqual(expected, actual);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderCellularLenghtInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = string.Empty;
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "722889597";
            string nit = "745218304";
            string telephone = "4444444";
            bool expected = true;
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
            Assert.AreEqual(expected, actual);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderContactNameLenghtInvalid()
        {
            string address = "Cañada cbba Esq Nestor Salazar #143";
            string contact = "asdfasdighasdiufhsoadfhpoasdhfoiashdfhasdfiuasodhfasiuodfhasiodufhasdiofhasiuodfhsdiuofhasdioufhasoidufhas";
            string email = string.Empty;
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderContactNameInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact ="'oroej";
            string email = string.Empty;
            string name = "Patito Productions" + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "74534562";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);
        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderEmailInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = "'javier@hotmail.com.bo";
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);

        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderEmailLenghtInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = "jaffffffffffffffddddddddddddddddddddddfffffffffffffffffffffffffffffffffvier@hotmail.com.bo";
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = string.Empty;
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);

        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderWebInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = "javier@hotmail.com.bo";
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = "www'.patitoweb.com.bo";
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);

        }
        [ExpectedException(typeof(BusinessException))]
        [TestMethod()]
        public void RegisterProviderWebLenghtInvalid()
        {
            string address = "Canada cbba Esq Nestor Salazar #143";
            string contact = string.Empty;
            string email = "javier@hotmail.com.bo";
            string name = "Patito Productions " + Convert.ToString(((new Random(1)).Next()));
            string web = "www'.patitoweb.com.bo";
            string cellular = "72288997";
            string nit = "745218304";
            string telephone = "4444444";
            bool actual;
            actual = ProviderControl.RegisterProvider(address, contact, email, name, web, cellular, nit, telephone);

        }
       
        
    }
}
